Date.prototype.format = function () {
  y = this.getFullYear();
  m = this.getMonth() + 1;
  d = this.getDate();
  H = this.getHours();
  M = this.getMinutes();
  S = this.getSeconds();
  if (m.toString().length === 1) m = '0' + m;
  if (d.toString().length === 1) d = '0' + d;
  return y + '-' + m + '-' + d + ' ' + H + ':' + M + ':' + S;
}

function getCookie (name) {
  var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
  return r ? r[1] : undefined;
}

function timestampToDate (timestamp) {
  return new Date(1000 * timestamp);
}

function objectIdToDate (oid) {
  return timestampToDate(Number.parseInt(oid.slice(0, 8), base=16));
}

function passwordConfirmation(pwd_id, cfm_id) {
  pwd = $(pwd_id);
  cfm = $(cfm_id);
  if (pwd.val() == cfm.val()) {
    return true;
  } else {
    pwd.val("");
    cfm.val("");
    return false;
  }
}
